﻿{% extends "zh_CN/base.html" %}

{% block head_title %}
<title>Odoo</title>
{% endblock %}


{% block body %}

<section class="breadcrumbs">
    <div class="breadcrumb-sm-images">
        <div class="inner-banner-1 magnetic-item">
            <img src="/www_xodoo_cn/static/templates/zh_CN/assets/img/inner-pages/inner-banner-1.png" alt>
        </div>
        <div class="inner-banner-2 magnetic-item">
            <img src="/www_xodoo_cn/static/templates/zh_CN/assets/img/inner-pages/inner-banner-2.png" alt>
        </div>
    </div>
    <div class="container">
        <div class="row">
            <div class="col-12">
                <div class="breadcrumb-wrapper">
                    <div class="breadcrumb-cnt">
                        <span> Odoo定制专家 </span>
                        <h1>"以教为交-以教为学"</h1>
                        <div class="breadcrumb-list">
                            <a href="/index">首页</a><img
                                src="/www_xodoo_cn/static/templates/zh_CN/assets/img/inner-pages/breadcrumb-arrow.svg"
                                alt> 联系我们
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<div class="contact-page-wrap sec-mar">
    <div class="container">
        <div class="row g-lg-4 gy-5">
            <div class="col-lg-6">
                <div class="contact-content">
                    <span>联系我们</span>
                    <h2>Odoo个性化全能专家</h2>
                    <p>从桌面端到移动端，再到WEB端我们都有解决方案，开源模式让我们可利用无数开发人员和业
                        务专家，在短短数年内，打造数百款应用。</p>
                    <div class="informations">
                        <div class="single-info">
                            <div class="icon">
                                <i class="fas fa-map-marker-alt"></i>
                            </div>
                            <div class="info">
                                <p>中国昆山市周市镇万华园7幢1221室</p>
                            </div>
                        </div>
                        <div class="single-info">
                            <div class="icon">
                                <i class="fas fa-phone-alt"></i>
                            </div>
                            <div class="info">
                                <a href="tel:13584935775">+086 135 8493 5775</a>
                            </div>
                        </div>
                        <div class="single-info">
                            <div class="icon">
                                <i class="far fa-envelope"></i>
                            </div>
                            <div class="info">
                                <a href="mailto:35350428@qq.com?cc=31800115@qq.com&subject=咨询Odoo&body=培训计划"><span
                                        class="__cf_email__"
                                        data-cfemail="026b6c646d42677a636f726e672c616d6f">35350428@qq.com</span></a>
                            </div>
                        </div>
                    </div>
                    <!--                    <div class="follow-area">-->
                    <!--                        <h5 class="blog-widget-title">Follow Us</h5>-->
                    <!--                        <p class="para">Follow us on Social Network</p>-->
                    <!--                        <div class="blog-widget-body">-->
                    <!--                            <ul class="follow-list d-flex flex-row align-items-start gap-4">-->
                    <!--                                <li><a href="https://www.facebook.com/"><i class="bx bxl-facebook"></i></a></li>-->
                    <!--                                <li><a href="https://www.twitter.com/"><i class="bx bxl-twitter"></i></a></li>-->
                    <!--                                <li><a href="https://www.instagram.com/"><i class="bx bxl-instagram"></i></a></li>-->
                    <!--                                <li><a href="https://www.pinterest.com/"><i class="bx bxl-pinterest"></i></a></li>-->
                    <!--                            </ul>-->
                    <!--                        </div>-->
                    <!--                    </div>-->

                </div>
                <a name="ask" id="ask"></a>
            </div>

            <div class="col-lg-6" id="message">

                <div class="contact-form-wrap" id="post_form">
                    <div class="form-tltle">
                        <h5>免费咨询</h5>

                    </div>
                    <div class="contact-form">
                        <form id="defaultForm" method="post" target="display_none" enctype="multipart/form-data"
                              onsubmit="return submitForm()">
                            <div class="row">
                                <div class="form-group col-md-6 mb-20">
                                    <div class="form-inner">
                                        <label>姓名</label>
                                        <input type="text" id="name" name="name" required>
                                    </div>
                                </div>
                                <div class="form-group col-md-6 mb-20">
                                    <div class="form-inner">
                                        <label>职务</label>
                                        <input type="text" id="subject" required>
                                    </div>
                                </div>
                                <div class="form-group col-lg-12 mb-20">
                                    <div class="form-inner">
                                        <label>公司</label>
                                        <input type="text" id="company" required>
                                    </div>
                                </div>
                                <div class="form-group col-lg-12 mb-20">
                                    <div class="form-inner">
                                        <label>邮件</label>
                                        <input type="email" id="email_from" placeholder="输入邮件" class="form-control"
                                               required>
                                    </div>
                                </div>
                                <div class="form-group col-lg-12 mb-20">
                                    <div class="form-inner">
                                        <label>手机</label>
                                        <input type="text" id="phone" required>
                                    </div>
                                </div>
                                <div class="form-group col-lg-12 mb-20">
                                    <div class="col-md-12 form-inner">
                                        <label>咨询内容</label>
                                        <textarea id="description" class="form-control" onkeyup='textAreaChange(this)'
                                                  onkeydown='textAreaChange(this)' rows='3'
                                                  required></textarea>

                                        <div class='text-right' style="float:right;">
                                            <em style='color:#06D889'>50</em>/<span style='color:#FFFFFF'>50</span>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-12">
                                    <div class="form-inner">
                                        <button class="primary-btn3" type="submit">提交</button>
                                        <input id="csrf_token" name="csrf_token" value="{{object.csrf_token}}" hidden/>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}

{% block my_script %}
<script type="text/javascript">


    function Request(strName) {
        var strHref = location.href;
        var intPos = strHref.indexOf("?");
        var strRight = strHref.substr(intPos + 1);
        var arrTmp = strRight.split("&");
        for (var i = 0; i < arrTmp.length; i++) {
            var arrTemp = arrTmp[i].split("=");
            if (arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1];
        }
        return "";
    }

    document.getElementById("description").value = decodeURI(Request("name"));


    //显示限制输入字符method
    function textAreaChange(obj) {
        var $this = $(obj);
        var count_total = $this.next().children('span').text();
        var count_input = $this.next().children('em');
        var area_val = $this.val();
        if (area_val.len() > count_total) {
            area_val = autoAddEllipsis(area_val, count_total);//根据字节截图内容
            $this.val(area_val);
            count_input.text(0);//显示可输入数
        } else {
            count_input.text(count_total - area_val.len());//显示可输入数
        }
    }

    //得到字符串的字节长度
    String.prototype.len = function () {
        return this.replace(/[^\x00-\xff]/g, "xx").length;
    };

    /*
     * 处理过长的字符串，截取并添加省略号
     * 注：半角长度为1，全角长度为2
     * pStr:字符串
     * pLen:截取长度
     * return: 截取后的字符串
     */
    function autoAddEllipsis(pStr, pLen) {
        var _ret = cutString(pStr, pLen);
        var _cutFlag = _ret.cutflag;
        var _cutStringn = _ret.cutstring;
        return _cutStringn;
    }

    /*
     * 取得指定长度的字符串
     * 注：半角长度为1，全角长度为2
     * pStr:字符串
     * pLen:截取长度
     * return: 截取后的字符串
     */
    function cutString(pStr, pLen) {
        // 原字符串长度
        var _strLen = pStr.length;
        var _tmpCode;
        var _cutString;
        // 默认情况下，返回的字符串是原字符串的一部分
        var _cutFlag = "1";
        var _lenCount = 0;
        var _ret = false;
        if (_strLen <= pLen / 2) {
            _cutString = pStr;
            _ret = true;
        }
        if (!_ret) {
            for (var i = 0; i < _strLen; i++) {
                if (isFull(pStr.charAt(i))) {
                    _lenCount += 2;
                } else {
                    _lenCount += 1;
                }
                if (_lenCount > pLen) {
                    _cutString = pStr.substring(0, i);
                    _ret = true;
                    break;
                } else if (_lenCount == pLen) {
                    _cutString = pStr.substring(0, i + 1);
                    _ret = true;
                    break;
                }
            }
        }
        if (!_ret) {
            _cutString = pStr;
            _ret = true;
        }
        if (_cutString.length == _strLen) {
            _cutFlag = "0";
        }
        return {"cutstring": _cutString, "cutflag": _cutFlag};
    }

    /*
     * 判断是否为全角
     *
     * pChar:长度为1的字符串
     * return: true:全角
     *         false:半角
     */
    function isFull(pChar) {
        if ((pChar.charCodeAt(0) > 128)) {
            return true;
        } else {
            return false;
        }
    }

    //执行输入字符统计
    $(function () {
        textAreaChange(document.getElementById("description"));
    });

</script>
<script>


    function submitForm() {
        $.ajax({
            url: "/contact/crm.lead",
            type: "POST",
            async: false,
            contentType: "application/json;charset=utf-8",
            data: JSON.stringify({
                "name": document.getElementById("name").value,
                "subject": document.getElementById("subject").value,
                "company": document.getElementById("company").value,
                "email_from": document.getElementById("email_from").value,
                "phone": document.getElementById("phone").value,
                "description": document.getElementById("description").value,
                "csrf_token": document.getElementById("csrf_token").value,
            }),
            success: function (data) {
                result = data.result
                let res = JSON.parse(result)

                if (res.errmsg === 'yes') {
                    console.log("success")
                    // location.reload()
                    var message = document.getElementById("message");
                    var post_form = document.getElementById("post_form");
                    post_form.remove();
                    var newTodoHTML = `
                            <div class="error-page-bg">
                    <div class="container">
                        <div class="row">
                            <div class="col-lg-12 d-flex align-items-center">
                                <div class="error-content">
                                    <h1>您的信息提交成功 <span>稍后工作人员将与您取得联系！</span></h1>
                                    <p>Amos Odoo实施专家将为您提供，全方位的产品咨询.</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                              `;
                    var dummy = document.createElement("DIV");
                    dummy.innerHTML = newTodoHTML;
                    message.appendChild(dummy);
                } else {
                    console.log("error")
                }
            },
            error: function () {
            }
        });
    }
</script>
}
{% endblock %}

